package com.wfl.excel.demo.service.impl;

import com.wfl.excel.demo.entity.Excel;
import com.wfl.excel.demo.mapper.ExcelMapper;
import com.wfl.excel.demo.service.IExcelService;
import com.wfl.excel.demo.util.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class ExcelServiceImpl implements IExcelService {

    @Autowired
    private ExcelMapper excelMapper;
    @Override
    public void importExcel(String path) {
        List<Excel> list = ExcelUtil.importExcel(path);
        excelMapper.insertAllUsers(list);
    }

    @Override
    public void exportExcel(String path) {
        List<Excel> list = excelMapper.findAllUser();
        ExcelUtil.exportExcel(path,list);
    }
}
